import { ref } from 'vue'
import { defineStore } from 'pinia'

export const useUserStore = defineStore(
  'user',
  () => {
    const username = ref('')
    const nickName = ref('')
    const token = ref('')
    const reset = () => {
      username.value = ''
      nickName.value = ''
      token.value = ''
    }
    const setUsername = (id) => {
      username.value = id
    }
    const setNickName = (name) => {
      nickName.value = name
    }
    const setToken = (newToken) => {
      token.value = newToken
    }
    return {
      username,
      reset,
      token,
      setUsername,
      setToken,
      nickName,
      setNickName
    }
  },
  {
    persist: true
  }
)
